package com.wisecoach.gatewayplus.transaction.lockedtx;

import com.wisecoach.gatewayplus.transaction.TransactionAdvice;

import java.lang.reflect.Method;

/**
 * {@code @author:} wisecoach
 * {@code @date:} 2023/9/26 上午10:00
 * {@code @version:} 1.0.0
 */


public class LockedTxAdvice implements TransactionAdvice {

    private final LockedTxConsumer consumer;

    public LockedTxAdvice(LockedTxConsumer consumer) {
        this.consumer = consumer;
    }
    
    @Override
    public void before(Method method, Object[] args, Object target) {
        consumer.beforeConsume();
    }

    @Override
    public void afterReturning(Object ret, Method method, Object[] args, Object target) {
        consumer.consumeOnReturn();
    }

    @Override
    public void throwing(Method method, Object[] args, Object target, Throwable t) throws Throwable {
        consumer.consumeOnThrow();
    }
}
